﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="StandardCustomerEstimat.aspx.cs" Inherits="AnalyseCRM.Operation.StandardCustomerEstimat" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>证券行业分析型客户关系管理之标准客资产估算</title> 
    <link href="/Styles/index.css" rel="stylesheet" type="text/css" />        
    <link rel="stylesheet" type="text/css" href="../Scripts/jquery-ui-multiselect-widget-master/jquery.multiselect.css" />
    <link rel="stylesheet" type="text/css" href="../Scripts/jquery-ui-multiselect-widget-master/demos/assets/style.css" />
    <link rel="stylesheet" type="text/css" href="../Scripts/jquery-ui-multiselect-widget-master/demos/assets/prettify.css" />
    <link rel="stylesheet" type="text/css" href="../Scripts/jquery-ui-1.9.1.custom/development-bundle/themes/ui-lightness/jquery-ui.css" />
    <link href="/Styles/common.css" rel="stylesheet" type="text/css" /> 
    <script type="text/javascript" src="../Scripts/jquery-ui-1.9.1.custom/js/jquery-1.8.2.js"></script>
    <script type="text/javascript" src="../Scripts/Common.js"></script> 
    <script type="text/javascript" src="../Scripts/jquery-ui-1.9.1.custom/js/jquery-ui-1.9.1.custom.min.js"></script>
    <script type="text/javascript" src="../Scripts/jquery-ui-multiselect-widget-master/demos/assets/prettify.js"></script>
    <script type="text/javascript" src="../Scripts/jquery-ui-multiselect-widget-master/src/jquery.multiselect.js"></script>
    <script type="text/javascript" src="../Highcharts/js/highcharts.js"></script>
    <script type="text/javascript" src="../Highcharts/js/modules/exporting.js"></script>
    <script language="javascript" type="text/javascript">
        var oHtml = "";
        $(function () {
            $("#selcondtion").multiselect({
                position: { my: 'left bottom', at: 'left top' },
                click: function (event, ui) {
                    if (ui.checked) {
                        changecondition(ui.value, ui.text);
                    }
                    else {
                        deleteselrow(ui.value);
                    }
                }
            });

            IsExistsEstimationGuest();
            IsExistsEstimationChart();

            $("#exprotin").click(function () {
                var lens, extname;
                lens = $("#openfile").val().toLowerCase().length;
                extname = $("#openfile").val().substring(lens - 4, lens);
                if (extname != '.xls') {
                    window.alert('请选择后缀名为(xls)的文件!');
                    $("#openfile").focus();
                    return false;
                }
                //beginFunc();
                var strls = "", i = 2;
                var guestarray = new Array();
                var xls = new ActiveXObject("Excel.Application");
                var xlBook = xls.Workbooks.Open($("#openfile").val());
                var xlsheet = xlBook.Worksheets(1);
                while ((xlsheet.Cells(i, 4).value != undefined) && (xlsheet.Cells(i, 5).value != undefined)
                        && (xlsheet.Cells(i, 6).value != undefined) && (xlsheet.Cells(i, 7).value != undefined)) {
                    strls = xlsheet.Cells(i, 1).value + '|'
                            + xlsheet.Cells(i, 2).value + '|' + xlsheet.Cells(i, 3).value + '|'
                            + xlsheet.Cells(i, 4).value + '|' + xlsheet.Cells(i, 5).value + '|'
                            + xlsheet.Cells(i, 6).value + '|' + xlsheet.Cells(i, 7).value + '|'
                            + xlsheet.Cells(i, 8).value + '|' + xlsheet.Cells(i, 9).value + '|'
                            + xlsheet.Cells(i, 10).value + '|0';
                    if ((xlsheet.Cells(i, 8).value != undefined) || (xlsheet.Cells(i, 9).value != undefined)
                            || (xlsheet.Cells(i, 10).value != undefined)) {
                        guestarray.push(strls);
                    }
                    i++;
                }
                i = i - 2;
                jQuery.ajax({
                    type: "post",
                    url: "/InteractiveData/StandardCustomerAjax.aspx",
                    data: "paramvalue=" + escape(guestarray) + "&paramtype=InsertEstimationGuest",
//                    beforeSend: function () {
//                        beginFunc();
//                    },
                    success: function (message) {
                        if (message == "SUCCESS") {
                            endFunc();
                            $("#divpgtsh").html("成功导入" + i.toString() + "条客户资料，成功率100%");
                        }
                        else {
                            $("#divpgtsh").html("估算失败！");
                        }
                    },
                    error: function () {
                        $("#divpgtsh").html("连接服务是发生异常！");
                    }
                });
                xlBook.Close();
                xls.Application.Quit()
                xls = null;
            }); // end of exprotin click
            $("#zichangusuan").click(function () {
                jQuery.ajax({
                    type: "post",
                    url: "/InteractiveData/StandardCustomerAjax.aspx",
                    data: "paramvalue=&paramtype=builderEstimationGues",
                    beforeSend: function () {
                        //beginFunc();
                    },
                    success: function (message) {
                        if (message == "SUCCESS") {
                            endFunc();
                            $("#divpgtsh").html("估算成功！");
                            buildzEstimation();
                            buildmEstimation();
                        }
                    },
                    error: function () {
                        $("#divpgtsh").html("连接服务是发生异常！");
                    }
                });
            });  //end of zichangusuan click
            BindDictSelect("2", "#selgszixiang");
            $("#lastresult").click(function () {
                buildzEstimation();
                buildmEstimation();
            });  //end of lastresult click
        });
        function changecondition(selid, seltext) {
            oHtml += "<tr id=tr" + selid + "><td style=\"text-align:right;\">" + seltext + ":<input id=instart" + selid + " type =\"text\" value=\"0.00\" />-<input id=inend" 
                                 + selid + " type =\"text\" value=\"0.00\" /></td></tr>";
            $("#tblcondition").html(oHtml);
            parent.window.iFrameHeight();
        }
        function deleteselrow(selid) {
            var selrow = "tr"+selid;
            var rowIn = document.getElementById(selrow).rowIndex;
            document.getElementById("tblcondition").deleteRow(rowIn);
            oHtml = $("#tblcondition").html();
        }
        function buildzEstimation() {
            var pValue = "F01901";
            jQuery.ajax({
                type: "post",
                url: "/InteractiveData/StandardCustomerAjax.aspx",
                data: "paramvalue=" + escape(pValue) + "&paramtype=BuilderChartF01901",
                success: function (message) {
                    if (message != "NONE") {
                        var data = eval("(" + message + ")");
                        //alert(data.categories);
                        var char1 = new Highcharts.Chart({
                            chart: {
                                renderTo: 'zEstimation',
                                type: 'column'
                            },
                            credits: {
                                enabled: false     //去掉highcharts网站url  
                            },
                            title: {
                                text: data.charttitle
                            },
                            xAxis: {
                                categories: eval(data.categories),
                                labels: {
                                    rotation: -45,
                                    align: 'right',
                                    style: {
                                        fontSize: '11px',
                                        fontFamily: 'Verdana, sans-serif'
                                    }
                                }
                            },
                            yAxis: {
                                allowDecimals: false,
                                min: 0,
                                title: {
                                    text: ''
                                }
                            },
                            tooltip: {
                                formatter: function () {
                                    return '<b>' + this.x + '</b><br/>' +
                        this.series.name + ': ' + this.y + '<br/>' +
                        '合计: ' + this.point.stackTotal;
                                }
                            },
                            plotOptions: {
                                column: {
                                    stacking: 'normal',
                                    dataLabels: {
                                        enabled: true,
                                        color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) || 'white'
                                    }
                                }
                            },
                            series: [{
                                name: data.seriesname,
                                data: eval(data.seriesdata)
                            }]
                        });                        
                    }
                    else {
                        $("#divpgtsh").html("估算失败！");
                    }
                },
                error: function () {
                    $("#divpgtsh").html("连接服务是发生异常！");
                }
            });
        }  // end of buildzEstimation
        function buildmEstimation() {
            var pValue = "F01902|"+$("#selgszixiang").val();
            jQuery.ajax({
                type: "post",
                url: "/InteractiveData/StandardCustomerAjax.aspx",
                data: "paramvalue=" + escape(pValue) + "&paramtype=BuilderChartF01902",
                success: function (message) {
                    if (message != "NONE") {                        
                        var data = eval("(" + message + ")");
                        var char2 = new Highcharts.Chart({
                            chart: {
                                renderTo: 'mEstimation',
                                type: 'column'
                            },
                            credits: {
                                enabled: false     //去掉highcharts网站url  
                            },
                            title: {
                                text: ''
                            },
                            xAxis: {
                                categories: eval(data.categories),
                                labels: {
                                    rotation: -45,
                                    align: 'right',
                                    style: {
                                        fontSize: '11px',
                                        fontFamily: 'Verdana, sans-serif'
                                    }
                                }
                            },
                            yAxis: {
                                allowDecimals: false,
                                min: 0,
                                title: {
                                    text: ''
                                }
                            },
                            tooltip: {
                                formatter: function () {
                                    return '<b>' + this.x + '</b><br/>' +
                        this.series.name + ': ' + this.y + '<br/>' +
                        '合计: ' + this.point.stackTotal;
                                }
                            },
                            plotOptions: {
                                column: {
                                    stacking: 'normal',
                                    dataLabels: {
                                        enabled: true,
                                        color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) || 'white'
                                    }
                                }
                            },
                            series: [{
                                name: data.seriesname,
                                data: eval(data.seriesdata)
                            }]
                        });
                        $("#divprocess").hide();
                    }
                    else {
                        $("#divpgtsh").html("估算失败！");
                    }
                },
                error: function () {
                    $("#divpgtsh").html("连接服务是发生异常！");
                }
            });
        }   // end of buildmEstimation

        function estimatguestfound() {
            //beginFunc();
            SearchQuery();
        } // end of estimatguestfound

        function SearchQuery(cPage, pSize) {
            if (!arguments[0]) cPage = _cPage;
            if (!arguments[1]) pSize = _pSize;
            var selcon = $("#selcondtion").val().toString().split(',');
            var pValue = "";
            for (var i = 0; i < selcon.length; i++) {
                var startdec = $("#instart" + selcon[i]).val();//);parseFloat(
                var enddec = $("#inend" + selcon[i]).val();//);parseFloat(
                pValue += selcon[i] + ',' + startdec.toString() + ',' + enddec.toString() + "|";
            }
            pValue = pValue + cPage + "|" + pSize;
            jQuery.ajax({
                type: "post",
                url: "/InteractiveData/StandardCustomerAjax.aspx",
                data: "paramvalue=" + escape(pValue) + "&paramtype=getEstimationGuestList",
                beforeSend: function () {
                    //beginFunc();
                },
                success: function (message) {
                    if (message != "error") {
                        var arr = message.split("$");
                        BindQueryList(arr[0]);
                        SetPager(cPage, arr[1], "#pager_container", pSize);
                        parent.window.iFrameHeight();
                        endFunc();
                    }
                },
                error: function () {
                    $("#divpgtsh").html("连接服务是发生异常！");
                }
            });
        }  // end of SearchQuery

        // 绑定查询记录
        function BindQueryList(message) {
            var oHtml = "";
            if (message == "none") { $("#search_result").html("<tr><td colspan=12>未查询到相关记录！</td></tr>"); return; }
            var list = eval("(" + message + ")").EstimationGuestMana;
            for (var i = 0; i < list.length; i++) {
                var data = list[i];
                oHtml += "<tr>";                             
                oHtml += "<td>" + data.guestname + "</td>";
                oHtml += "<td>" + data.relphone + "</td>";
                oHtml += "<td>" + data.crenumber + "</td>";
                oHtml += "<td>" + data.guestcity + "</td>";
                oHtml += "<td>" + data.guestcitypy + "</td>";
                oHtml += "<td>" + data.guestage + "</td>";
                oHtml += "<td>" + data.guestsex.toString() + "</td>";
                oHtml += "<td>" + data.homeaddr + "</td>";
                oHtml += "<td>" + data.assets.toString() + "</td>";
                oHtml += "<td>" + data.carvalue.toString() + "</td>";
                oHtml += "<td>" + data.assetsgroup.toString() + "</td>";
                oHtml += "<td>" + data.estimatvalue.toString() + "</td>";
                oHtml += "</tr>";
            }
            jQuery("#search_result").html(oHtml);
        }

        //导出接触数据
        function ExportContact() {
            var selcon = $("#selcondtion").val().toString().split(',');
            var pValue = "";
            for (var i = 0; i < selcon.length; i++) {
                pValue += selcon[i] + ',' + $("#instart" + selcon[i]).val() + ',' + $("#inend" + selcon[i]).val() + "|";
            }
            pValue = pValue.substring(0, pValue.length - 1);
            jQuery.ajax({
                type: 'post',
                url: "/InteractiveData/StandardCustomerAjax.aspx",
                data: "paramvalue=" + escape(pValue) + "&paramtype=exportEstimationGuest",
                cache: false,
                success: function (message) {
                    if (message != "error") {
                        var arr = message.split("$");
                        ExportContactToExcel(arr[0]);
                    }
                }, error: function () { }
            });
        }
        function ExportContactToExcel(message) //读取表格中每个单元到EXCEL中  
        {
            try {
                //var curTbl = document.getElementById(tableId);
                var oXL = new ActiveXObject("Excel.Application");
                //创建AX对象excel  
                var oWB = oXL.Workbooks.Add();
                //获取workbook对象  
                var oSheet = oWB.ActiveSheet;

                //var lenRow = rowcount; // curTbl.rows.length;
                //取得表格行数              
                oSheet.Cells(1, 1).value = "客户姓名";
                oSheet.Cells(1, 2).value = "联系号码";
                oSheet.Cells(1, 3).value = "证件号码";
                oSheet.Cells(1, 4).value = "客户城市(中文)";
                oSheet.Cells(1, 5).value = "客户城市(拼音)";
                oSheet.Cells(1, 6).value = "年龄";
                oSheet.Cells(1, 7).value = "性别";
                oSheet.Cells(1, 8).value = "家庭地址";
                oSheet.Cells(1, 9).value = "金融资产";
                oSheet.Cells(1, 10).value = "车价";
                oSheet.Cells(1, 11).value = "资产估算组合";
                oSheet.Cells(1, 12).value = "估算资产";
                var list = eval("(" + message + ")").EstimationGuestMana;
                oSheet.Columns(2).NumberFormatLocal = "@";
                oSheet.Columns(3).NumberFormatLocal = "@";
                for (var i = 0; i < list.length; i++) {
                    var data = list[i];
                    oSheet.Cells(i + 2, 1).value = data.guestname;
                    oSheet.Cells(i + 2, 2).value = data.relphone;
                    oSheet.Cells(i + 2, 3).value = data.crenumber;
                    oSheet.Cells(i + 2, 4).value = data.guestcity;
                    oSheet.Cells(i + 2, 5).value = data.guestcitypy;
                    oSheet.Cells(i + 2, 6).value = data.guestage;
                    oSheet.Cells(i + 2, 7).value = data.guestsex;
                    oSheet.Cells(i + 2, 8).value = data.homeaddr;
                    oSheet.Cells(i + 2, 9).value = data.assets;
                    oSheet.Cells(i + 2, 10).value = data.carvalue
                    oSheet.Cells(i + 2, 11).value = data.assetsgroup;
                    oSheet.Cells(i + 2, 12).value = data.estimatvalue;
                }
                oXL.Visible = true;
                //oXL.Application.Quit();
                //设置excel可见属性  
            } catch (e) {
                if ((! +'\v1')) { //ie浏览器  
                    alert("无法启动Excel，请确保电脑中已经安装了Excel!\n\n如果已经安装了Excel，" + "请调整IE的安全级别。\n\n具体操作：\n\n" + "工具 → Internet选项 → 安全 → 自定义级别 → ActiveX 控件和插件 → 对未标记为可安全执行脚本的ActiveX 控件初始化并执行脚本 → 启用 → 确定");
                } else {
                    alert("请使用IE浏览器进行“导入到EXCEL”操作！");  //方便设置安全等级，限制为ie浏览器  
                }
            } finally {
                oXL.Application.Quit();
            }
        }
        // 是否存在评估客户
        function IsExistsEstimationGuest() {
            jQuery.ajax({
                type: 'post',
                url: "/InteractiveData/StandardCustomerAjax.aspx",
                data: "paramvalue=&paramtype=IsExistsEstimationGuest",
                cache: false,
                success: function (message) {
                    if (message <= "0") {
                        $("#zichangusuan").attr('disabled', eval('true'));
                    }
                }, error: function () { }
            });
        }
        // 是否存在图表
        function IsExistsEstimationChart() {
            jQuery.ajax({
                type: 'post',
                url: "/InteractiveData/StandardCustomerAjax.aspx",
                data: "paramvalue=&paramtype=IsExistsEstimationChart",
                cache: false,
                success: function (message) {
                    if (message <= "0") {
                        $("#lastresult").attr('disabled', eval('true'));
                    }
                }, error: function () { }
            });
        }
    </script>   
</head>
<body>
    <form id="form1" runat="server">
    <div class="Pathlist">
        <ul>
            <li><a><strong>您当前所在的位置：</strong>标准客资产估算 ><strong>标准客资产估算</strong></a></li>
        </ul>
    </div>
    <div class="wrapper">
        <div class="Assesstablebox">            
            <div class="Assetstop">
                <input type="file" id="openfile" accept="application/msexcel" style="width: 490px;" /><br />
                <input id="exprotin" name="" type="button" value="请导入外部数据 " />
                <input id="zichangusuan" name="" type="button" value="进行资产估算 " />
                <input id="lastresult" name="" type="button" value="查看最后一次估算结果 " />
                <div id="divpgtsh"></div>
                </div>
                <div style="clear: both">
                </div>
        </div>
        <!--风格一，sharp color1-->
        <div class="wrapperbox">
            <ul>
                <li>
                  <div class="sharp color1">
                      <b class="b1"></b><b class="b2"></b><b class="b3"></b><b class="b4"></b>
                      <div class="content">                        
                        <div class="content-top">
                                <a>估算客户估算资产分段一</a> <span>
                                    <img alt="" src="/Images/bigicon.png" width="14" height="14" /></span></div>
                        <div id="zEstimation" class="contentbox" style="height:243px;">
                        </div>
                      </div>
                      <b class="b5"></b><b class="b6"></b><b class="b7"></b><b class="b8"></b>
                  </div>
                </li>
                <li>
                    <div class="sharp color1">
                        <b class="b1"></b><b class="b2"></b><b class="b3"></b><b class="b4"></b>
                        <div class="content">
                            <div class="content-top">
                                <a>估算客户估算资产分段二 </a><span>
                                    <img alt="" src="/Images/bigicon.png" width="14" height="14" /></span></div>
                            <div class="Checkboxes">
                                <label style="font-family:宋体; font-size:12px; color:White; font-weight:bold;"> 估算事项&nbsp;&nbsp;</label>
                                <select id="selgszixiang" onchange="buildmEstimation();" style="width: 200px;">
                                </select>
                            </div>
                            <div id="mEstimation" class="contentbox">
                                
                            </div>
                        </div>
                        <b class="b5"></b><b class="b6"></b><b class="b7"></b><b class="b8"></b>
                    </div>
                </li>
            </ul>
            <div style="clear: both">
            </div>
        </div>
        <div class="redline">
            <span></span><a>资产估算名单导出</a></div>
        <div class="Graysharp color2">
            <b class="b1"></b><b class="b2"></b><b class="b3"></b><b class="b4"><span class="blockcontent">
                <img alt="" src="/Images/jiaoyibanner01.png" width="421" height="238" /></span></b>
            <div class="content">
                <div class="Grayinput">
                    <div class="Assessboxtopleft0">
                        <a>请选择筛选的条件&nbsp;</a>
                        <div id="divselect">
                            <select id="selcondtion" multiple="multiple" style="width: 200px;">
                                <option value="1">只有房产项的估算</option>
                                <option value="2">只有车产项的估算</option>
                                <option value="3">只有金融资产项的估算</option>
                                <option value="4">房产+车产项的估算</option>
                                <option value="5">房产+金融资产项的估算</option>
                                <option value="6">车产+金融资产项的估算</option>
                                <option value="7">金融资产+房产+车产项的估算</option>
                            </select>
                        </div>
                        <span><input id="found" type="button" class="Assessinput"
                                     onclick="estimatguestfound();" value = "查询"/></span>
                    </div>
                    <div style="clear: both">
                    </div>
                </div>
                <div class="Assessgraybox">
                    <ul>
                        <li>
                            <table id="tblcondition">
                            </table>
                        </li>
                        <li class="Assessgraybox0"><strong>清单列表</strong>
                                <span><input id="exportout" name="" type="button" onclick="javascript:ExportContact();" value="导出数据"  /></span>                        
                                <div style="width: 90%; border: solid 1px #dcdcd;">
                                    <div id="divcontactlist" class="accordion_child0">
                                        <table class="tabler" id="hacker" cellspacing="0">
                                            <tr class="trbj">
                                                <td class="DmpData1"><a href="javascript:void(0);">客户姓名</a></td>
                                                <td class="DmpData1"><a href="javascript:void(0);">联系号码</a></td>
                                                <td class="DmpData1"><a href="javascript:void(0);">证件号码</a></td>
                                                <td class="DmpData1"><a href="javascript:void(0);">客户城市(中文)</a></td>
                                                <td class="DmpData1"><a href="javascript:void(0);">客户城市(拼音)</a></td>
                                                <td class="DmpData1"><a href="javascript:void(0);">年龄</a></td>
                                                <td class="DmpData1"><a href="javascript:void(0);">性别</a></td>
                                                <td class="DmpData1"><a href="javascript:void(0);">家庭地址</a></td>
                                                <td class="DmpData1"><a href="javascript:void(0);">金融资产</a></td>
                                                <td class="DmpData1"><a href="javascript:void(0);">车价</a></td>
                                                <td class="DmpData1"><a href="javascript:void(0);">资产估算组合</a></td>
                                                <td class="DmpData1"><a href="javascript:void(0);">估算资产</a></td>
                                            </tr>
                                            <tbody id="search_result">
                                            </tbody>
                                        </table>
                                        <div class="pagination" id="pagination-clean">
                                            <div id="pager_container">
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            <div style="clear: both">
                            </div>
                        </li>
                    </ul>
                </div>
            </div>
            <b class="b5"></b><b class="b6"></b><b class="b7"></b><b class="b8"></b>
        </div>
        <div id="divprocess" style="display: none; border: 1px solid Gray; background-color: #dcdcdc;
                                    width: 400px; height: 50px; text-align: center;z-index:1000;">
            正在处理提交数据,请稍候...<br />
            <img alt="" src="../Images/Atlas/indicator_mozilla_blu.gif" />
        </div>
        <div style="clear: both">
        </div>
    </div>
    <div class="foot">
        <a>版权所有：深圳华策略科技有限公司</a></div>
    </form>
</body>
</html>
